/**
 * Created by Administrator on 2017/2/27.
 */
const koa = require('koa');
const app = new koa();
const koaBody = require('koa-body');
const rest = require('./rest');
const controller = require('./controller');


const isProduction = process.env.NODE_ENV === 'production';//判断是生产环境还是开发环境
//解析body参数
app.use(koaBody());


//处理静态资源
if (! isProduction) {
    let staticFiles = require('./static-files');
    app.use(staticFiles('/static/', __dirname + '/static'));
}

//注册restApi
app.use(rest.restify());


//处理controller
app.use(controller());



//开启监听端口
app.listen(8000);